package com.mav.service.iml;

import com.mav.mapper.EmpMapper;
import com.mav.mapper.StudentMapper;
import com.mav.pojo.ClazzOption;
import com.mav.pojo.JobOption;
import com.mav.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class ReportServiceIml implements ReportService {
    @Autowired
    EmpMapper empMapper;
    @Autowired
    StudentMapper studentMapper;
    @Override
    public JobOption getEmpJobData() {
        List<Map<String, Object>> list = empMapper.CountEmpJobData();
        log.info("获得的信息:{}",list);
        List<Object> pos = list.stream().map(dataMap -> dataMap.get("pos")).toList();
        List<Object> num = list.stream().map(dataMap -> dataMap.get("num")).toList();
        return new JobOption(pos,num);
    }

    @Override
    public List<Map<String, Object>> getEmpGenderData() {
        return empMapper.CountEmpGenderData();
    }

    @Override
    public List<Map<String, Object>> getStudentDegreeData() {
        return studentMapper.CountStudentDegreeData();

    }

    @Override
    public ClazzOption getStudentCountData() {
        List<Map<String, Object>> list = studentMapper.studentCountData();
        log.info("获得的信息:{}",list);
        List<Object> clazz = list.stream().map(dataMap -> dataMap.get("clazzName")).toList();
        List<Object> num = list.stream().map(dataMap -> dataMap.get("num")).toList();
        return new ClazzOption(clazz,num);
    }
}
